#coding:utf8
from random import randint, sample

s1 = {x: randint(1, 4) for x in sample('abcdef', randint(0, 6))}
s2 = {x: randint(1, 4) for x in sample('abcdef', randint(0, 6))}
s3 = {x: randint(1, 4) for x in sample('abcdef', randint(0, 6))}

print(s1)
print(s2)
print(s3)

#方法一
for i in s1:
    if i in s2 and i in s3:
        print(i)

#方法二
#python3不支持view
# print(s1.viewitems())
# print(s1.items())
# print(s1.viewkeys())
# print(s1.keys())
# print(s1.viewvalues())
# print(s1.values())


print(s1.viewkeys() & s2.viewkeys() & s3.viewkeys())


#多轮比赛时,使用高级函数
print(reduce(lambda x, y:x & y, map(dict.viewkeys, [s1, s2 ,s3])))